package com.listeningframework.boot.codegen.generators.coders;

import com.listeningframework.boot.codegen.constants.Templates;
import com.listeningframework.boot.codegen.context.MetaContext;
import com.listeningframework.boot.codegen.exception.BusinessException;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * 
 * @description Service Coder
 *
 * @author lixining
 * @version $Id: ServiceCoder.java, v 0.1 2016年12月5日 下午1:52:44 lixining Exp $
 */
public class ServiceCoder extends AbstractCoder {

    public ServiceCoder(MetaContext context) {
        super(context);
    }

    @Override
    protected String getContent() throws BusinessException {
        return render(Templates.SERVICE);
    }

    @Override
    protected Map<String, Object> getParams() {
        Map<String, Object> paramMap = newHashMap();
        Set<String> imports = new HashSet<>();
        imports.add(context.getEntityClass());
        imports.add(context.getRepositoryClass());
        paramMap.put(CLASS_IMPORTS, imports);
        paramMap.put(CLASS_PACKAGE, context.getServicePackage());
        return paramMap;
    }

    @Override
    protected String getSavePath() throws BusinessException {
        return context.getServicePath();
    }

}
